package com.example.jyapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

import com.example.jyapplication.ui.LoginActivity;

public class SplashActivity extends AppCompatActivity {
    int count = 3;
    TextView tvCount;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tvCount = findViewById(R.id.tv_count);

        new Thread(new Runnable() {
            @Override
            public void run() {
                while (count>0){
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            tvCount.setText(count+"s");
                        }
                    });
                    count--;
                    if (count==0){
                        Intent intent = new Intent(SplashActivity.this,
                                LoginActivity.class);
                        startActivity(intent);
                    }
                }
            }
        }).start();
    }
}